<?php
require './model/Db.php';
$Db = DB::getInstance();
$user_data = $Db->islogin();
$isMobile = preg_match('/mobile/i', $_SERVER['HTTP_USER_AGENT']);
$target = $isMobile?'':'target="_blank"';
$zone_data = $Db->find([
	table => ['zone'],
	where => '1 order by sort,id'
]);
$data_arr = [];
foreach ($zone_data as $item) {
	$module_data = $Db->find([
		table => [zone => 'a',module => 'b'],
		field => 'b.name,b.id',
		where => "a.id = b.zid and a.id = {$item['id']}"
	]);
	$manager = json_decode($item['manager'])->uids;
	$uids = implode(',', $manager);
	if(!$uids){
		$uids = -1;
	}
	$username = $Db->find([
		table => ['bbs_user'],
		field => 'user,id',
		where => "id in ({$uids})"
	]);
	$item['module'] = $module_data;
	$item['manager'] = $username;
	$item['logo'] = mb_substr($item['name'], 0,1,'utf-8');
	$data_arr[] = $item;
}

$Db->close();
$web_title = '版面目录';
$css = [
	'public/css/my-bootstrap.min.css',
	'public/css/zone.all.min.css'
];
include './view/header.html';
include './view/zone.all.html';
include './view/footer.html';